#define _CRT_SECURE_NO_WARNINGS 1

typedef struct {
    ST stackpush;
    ST stackpop;
} MyQueue;


MyQueue* myQueueCreate() {
    MyQueue* queue = (MyQueue*)malloc(sizeof(MyQueue));

    STInit(&queue->stackpush);
    STInit(&queue->stackpop);

    return queue;
}

int myQueuePeek(MyQueue* obj) {
    if (!STEmpty(&obj->stackpop))
    {
        ;
    }
    else
    {
        while (!STEmpty(&obj->stackpush))
        {
            int front = STTop(&obj->stackpush);
            STPush(&obj->stackpop, front);
            STPop(&obj->stackpush);
        }
    }
    return STTop(&obj->stackpop);
}

void myQueuePush(MyQueue* obj, int x) {
    if (STEmpty(&obj->stackpush))
    {
        STPush(&obj->stackpush, x);
    }
    else
    {
        int front = myQueuePeek(obj);
        STPush(&obj->stackpush, x);
    }
}

int myQueuePop(MyQueue* obj) {
    int front;
    if (STEmpty(&obj->stackpop))
    {
        front = myQueuePeek(obj);
        STPop(&obj->stackpop);
    }
    else
    {
        front = STTop(&obj->stackpop);
        STPop(&obj->stackpop);
    }
    return front;
}

bool myQueueEmpty(MyQueue* obj) {
    return STEmpty(&obj->stackpop) && STEmpty(&obj->stackpush);
}

void myQueueFree(MyQueue* obj) {
    STDestroy(&obj->stackpush);
    STDestroy(&obj->stackpop);

    free(obj);
}